# encoding=utf-8

import time
import xmlrpclib

from flask import Flask, render_template
from flask import request, redirect, Blueprint

from cloud_testing.utils import register_ip, query_ip, save_report


# 漏扫的功能放到这里
leakage = Blueprint('leakage', __name__,
                       url_prefix='/leakage',
                       template_folder='templates',
                       static_folder='static')

@leakage.route('/route/<name>', methods=['GET', 'POST'])
def memory_route(name):
    if name == 'kvm':
        return kvm_init()
    elif name == 'qemu':
        return qemu_init()
    elif name == 'libvirt':
        return libvirt_init()
    else:
        return render_template('content.html',data={},welcomePage=False)
    
def kvm_init():
    introduce = {
        'content':u'写上自己需要的内容',
        'method':u'测试方法',
        'setup':u'设置：centos7，wireshark...',
        'testmethod':u'测试方式,点击按钮即可',
        'report':u'报告',
        'picture':'/static/img/openstack.jpg'
        }
    return render_template('content.html', introduce=introduce, welcomePage=False, nav_a=u'漏洞扫描', nav_b=u'kvm')

def qemu_init():
    introduce = {
        'content':u'写上自己需要的内容',
        'method':u'测试方法',
        'setup':u'设置：centos7，wireshark...',
        'testmethod':u'测试方式,点击按钮即可',
        'report':u'报告',
        'picture':'/static/img/openstack.jpg'
        }
    return render_template('content.html', introduce=introduce, welcomePage=False, nav_a=u'漏洞扫描', nav_b=u'qemu')

def libvirt_init():
    introduce = {
        'content':u'写上自己需要的内容',
        'method':u'测试方法',
        'setup':u'设置：centos7，wireshark...',
        'testmethod':u'测试方式,点击按钮即可',
        'report':u'报告',
        'picture':'/static/img/openstack.jpg'
        }
    return render_template('content.html', introduce=introduce, welcomePage=False, nav_a=u'漏洞扫描', nav_b=u'libvirt')

